<template>
	<view class="goods-item">
		<view class="goods-item-left">
			
			<radio :checked='v.goods_state' color="#c00000" v-if="showRadio" @click="radioChangeHandler"></radio>
			<image :src="v.goods_small_logo || defalutPic" class="goods-pic"></image>
		</view>
		<view class="goods-item-right">
			<view class="goods-name">
				{{v.goods_name}}
			</view>
			<view class="goods-info-box">
				<view class="goods-price">
					￥{{v.goods_price}}
				</view>
				<uni-number-box :min='1' :value="v.goods_count" v-if="showRadio" @change='numChangeHandler'></uni-number-box>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "my-goods",
		props: {
			v: {
				type: Object,
				default: {}
			},
			showRadio:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
				defalutPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-meium.png'
			};
		},
		methods:{
			radioChangeHandler(){
				this.$emit('radioChange',{goods_id:this.v.goods_id,goods_state:this.v.goods_state})
			},
			numChangeHandler(e){
				// console.log(e)
				this.$emit('numChange',{goods_id:this.v.goods_id,goods_count:+e})
			}
		}
	}
</script>

<style>
	.goods-item {
		display: flex;
		width: 750rpx;
		justify-content: space-between;
		margin: 10rpx 0;
		background-color: #fff;
		border-radius: 16rpx;
		box-sizing: border-box;
		box-shadow: 4rpx 4rpx 4rpx #eee;
	}
	.goods-item-left{
		display: flex;
		margin-right: 10rpx;
		justify-content: space-between;
		align-items: center;
	}
	.goods-item-left .goods-pic {
		width: 200rpx;
		height: 200rpx;
		display: block;
		
	}

	.goods-item-right {
		flex-grow: 1;
		margin-left: 40rpx;
		padding: 10rpx;
		font-size: 24rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		flex-direction: column;
	}

	.goods-item-right .goods-info-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-right: 20rpx;
	}
	.goods-info-box .goods-price{
		color: tomato;
		font-size: 32rpx;
	}
</style>
